/*
 * @Description:角色路由
 * @Version: 2.0
 * @Autor: kafei
 * @Date: 2021-11-19 14:42:57
 * @LastEditors: kafei
 * @LastEditTime: 2021-12-09 16:45:08
 */

const {
  roleController,
  findRoleServerController,
  findPageRoleServerController,
  updateRoleController
} = require('../controller/roleController')
const result = require('../utils/result')
const getRoleApi = (router) => {
  router.get('/role', async (ctx) => {
    const role = ctx.query.role
    if (!role) {
      return result('1', '请添加role参数!')
    }
    const resultData = await roleController(role)
    ctx.body = resultData
  })
  router.get('/getAllrole', async (ctx) => {
    const result = await findRoleServerController()
    ctx.body = result
  })
  router.get('/findPageRole', async(ctx) => {
    const result = await findPageRoleServerController(ctx)
    ctx.body = result
  })
  router.post('/updateRole', async (ctx) => {
    const result = await updateRoleController(ctx.request.body)
    ctx.body = result
  })
  router.post('/addRole', async (ctx) => {
    const result = await updateRoleController(ctx.request.body)
    ctx.body = result
  })
}
module.exports = getRoleApi
